<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8"/>
  <title>显示数据三种方案</title>
  <style>
    [v-cloak] {
      display: none;
    }
    span {
      display: inline-block;
      margin-right: 15px;
    }
  </style>
</head>
<body>

  <div id="app" v-cloak>
    <span>{{num}}</span><button @click="num++">添加</button>
    <br/>
    <button @click="destroyVm()">销毁组件</button>
  </div>
  
  <script src="../lib/vue.3.4.js"></script>
  <script>
/*
# 执行var app = Vue.createApp({}), 创建实例
beforeCreate 创建应用实例之前
created 实例创建完成之后

# 执行 app.mount('#app'), 实例挂载到DOM
beforeMount 实例挂载到指定DOM元素之前
mounted 实例挂载成功之后

beforeUpdate 实例修改之前
updated 实例修改之后

# 执行app.unmount()，卸载实例
beforeUnmount 实例卸载之前
unmounted 实例卸载之后
*/

    const app = Vue.createApp({
      data () {
        return {
          num: 1
        }
      },
      beforeCreate () {
        console.log('创建vm对象之前beforeCreate');
      },
      created () {
        console.log('创建vm对象完成之后created');
      },
      beforeMount () {
        console.log('准备插入之前beforeMount');
      },
      mounted () {
        console.log('插入完成mounted');
      },
      beforeUpdate () {
        console.log('修改属性之前beforeUpdate')
      },
      updated () {
        console.log('修改属性完成之后updated')
      },
      beforeUnmount () {
        console.log('移除vm对象之前beforeUnmount');
      },
      ummounted () {
        console.log('移除vm对象之后ummounted');
      },
      methods: {
        destroyVm () {
          app.unmount(); // 不存在这个方法，不知道怎么触发~~
        }
      }
    }).mount('#app');
  </script>
</body> 
</html>





